<%@page import="com.wanmait.hotelManage.vo.OfficialNews"%>
<%@page import="java.util.List"%>
<%@page import="com.wanmait.hotelManage.vo.Pager"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
	List<OfficialNews> officialNewss=(List<OfficialNews>)request.getAttribute("allOfficialNews");
	Pager pager=(Pager)request.getAttribute("pager");
	String path=request.getContextPath();
%>
<table id="tt" class="result-tab" width="100%">
                        <tr>
                            <th class="tc" width="5%"><input class="allChoose" name="" type="checkbox"></th>
                             <th>序号</th> 
                            <!-- <th>ID</th> -->
                            <th>标题</th>                         
                            <th>内容</th>
                            <th>发送时间</th>
                            <th>操作</th>
                        </tr>
                       <%  
                       	if(officialNewss!=null){
                        for(int i=0;i<officialNewss.size();i++){
                        	OfficialNews officialNews=officialNewss.get(i);
                        	/* out.print(roomType); */
                        	%>
                        	
                        	<tr id="tr<%=officialNews.getId()%>">
                        	
                               <td class="tc"><input data-id="<%=officialNews.getId() %>" class="choose" name="id[]" value="59" type="checkbox"></td>
                               <td width="80px"><%=i+1 %></td>  
                               <td width="150px"><%=officialNews.getTitle() %></td>  
                               <td ><%=officialNews.getContent() %></td>
                               <td width="200px"><%=officialNews.getInputTime() %></td>
   
                               <td width="80px" class="tt">  
                                   <a class="link-del"  id="del<%=officialNews.getId()%>" href="#">删除</a>
                               </td>
                           </tr>
                        <% 	
                        }
                       }
                       %>
                    </table>
            
            <!-- 显示数字 -->
						<div style="text-align: center;">
						<%
                    if(pager!=null){
                    	 int start= 1;
                         int end =pager.getPageCount();
                         if(pager.getPageCount()>5){
                        	 start=pager.getPageNo()-2<1?1:pager.getPageNo()-2;
                        	 end=start+4;
                        	 if(end>pager.getPageCount()){
                        		 end=pager.getPageCount();
                        		 start=end-4;
                        	 }
                         }
                         %>
                         [<a class="ok" href="javascript:void(0)">上一页</a>]
                         <%
                    	for(int i=start;i<=end;i++){
                    		if(pager.getPageNo()!=i){
                    		%>
                    		[<a class="number" href="javascript:void(0)"><%=i %></a>]
                    		<%
                    	}else{
                    		%>
                    		[<a class="aaa" href="javascript:void(0)"><%=i %></a>]
                    		<%
                    	}
                    }
                         %>
                         [<a class="no" href="javascript:void(0)">下一页</a>]
                         <%
                    }
                    %>
						</div>
	<!-- 显示数字的结束 --> 
                    
                    
                    
                    <script>
                    

            		$(".no").click(function(){
            			/* $(".number").css("color","black");
            			$(this).css("color","red"); */
            			var n=<%=pager.getPageNo()%>;
            			if(n<<%=pager.getPageCount()%>){
            				n++;
            			}
            			$.ajax({
            				url:"<%=path%>/manage/OfficialNewsServlet?action=getOfficialNewss",
            					data:{"pageNo":n},
            						success:function(msg){
            							$(".result-content").html(msg);
            						}
            			})
            		})
            		$(".ok").click(function(){
            		/* $(".number").css("color","black");
            		$(this).css("color","red"); */
            		var n=<%=pager.getPageNo()%>;
            		if(n>1){
            		n--;
            		}
            		$.ajax({
            		url:"<%=path%>/manage/OfficialNewsServlet?action=getOfficialNewss",
            		data:{"pageNo":n},
            			success:function(msg){
            				$(".result-content").html(msg);
            			}
            		})
            		})		

                    $(".link-del").click(function(){
        				if(!window.confirm("你确定要删除吗")){
        					return false;
        				}
        				var id=$(this).attr("id").substring(3);
        					
        				$.ajax({
        					url:"<%=path%>/manage/OfficialNewsServlet?action=delete",
        					data:{id:id,pageNo:<%=pager.getPageNo()%>},
        					success:function(msg){
        						$(".result-content").html(msg);
        					}
        				});
        			});
                    
                    </script>
                    <script>
						$(".aaa").css("color","red");
					</script>